package main

import (
	"fmt"
	"runtime/debug"
	"time"
)

// 使用debug查看GC
func printGCStats() {
	t := time.NewTicker(time.Second)
	s := debug.GCStats{}
	for {
		select {
		case <-t.C:
			debug.ReadGCStats(&s)
			fmt.Printf("gc %d last@%v, Pausetotal %v\n", s.NumGC, s.LastGC, s.PauseTotal)
		}
	}
}

func main() {
	go printGCStats()
	for i := 0; i < 10000; i++ {
		func() {
			_ = make([]byte, 1<<20)
		}()

	}
}
